﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;
using System.Text.RegularExpressions;
namespace Sunboxsoft.ASMS.Client.UI.Common.Validations
{
    /// <summary>
    /// 验证身份证号码格式
    /// </summary>
    public class TextEditIdNumberValidation : TextEditRegexValidation
    {
        /// <summary>
        /// 验证身份证号码格式
        /// </summary>
        /// <param name="textEdit"></param>
        public TextEditIdNumberValidation(TextEdit textEdit,bool isRequired)
            : base(textEdit, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", "身份证号码", isRequired)
        {
        }
        public override bool ValueChanging(string newValue)
        {
            Regex regex = new Regex(@"^(^\d{1,15}$|^\d{1,18}$|^\d{1,17}(\d|X|x))$");
            if (regex.IsMatch(newValue) && newValue.Length <= 18)
            {
                return true;
            }
            return false;
        }
    }
}
